package org.front;

import org.apache.commons.lang3.StringUtils;
import org.dao.ProductDao;
import org.dao.UserDao;
import org.entity.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

@Scope("prototype")
@Component("IndexAction")
public class IndexAction extends ActionSupport {
	private static final long serialVersionUID = 73496542982658911L;
	
	private String name;
	private String price;
	private String price1;
	
	@Autowired
	private ProductDao productDao;

	@Override
	public String execute() throws Exception {
		ActionContext context = ActionContext.getContext();
		Product product = new Product();
		if(StringUtils.isNotEmpty(name)){
			product.setName(name);
		}
		if(StringUtils.isNotEmpty(price) && StringUtils.isNotEmpty(price1)){
			product.setExt2(price);
			product.setExt3(price1);
		}
		context.put("cpzs", productDao.findAllList(product));
		return ActionSupport.SUCCESS;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	public String getPrice1() {
		return price1;
	}

	public void setPrice1(String price1) {
		this.price1 = price1;
	}

}
